package com.netty.modbus.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * description: DateUtil <br>
 * date: 2021/9/29 16:33 <br>
 * @author: lwy <br>
 * version: 1.0 <br>
 */
public  class DateUtil {
    private static final int checkNum=10;


    /**
     * 获取当年份后两位
     * */
    public static int getCurrentYear(){
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        int w = cal.get(Calendar.YEAR)-2000;
        return w;
    }

    /**
     * 获取当月份
     * */
    public static int getCurrentMonth(){
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        int w = cal.get(Calendar.MONTH)+1;
        return w;
    }

    /**
     * 获取当前日期
     * */
    public static int getCurrentDay(){
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        int w = cal.get(Calendar.DAY_OF_MONTH);
        return w;
    }

    /**
     * 获取当星期几
     * */
    public static int getCurrentWeek(){
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
        return w;
    }


    /**
     * 获取当前时间
     * */
    public static int getCurrentHours(){
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        int w = cal.get(Calendar.HOUR_OF_DAY);
        return w;
    }
    /**
     * 获取当前分钟
     * */
    public static int getCurrentMinutes(){
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        int w = cal.get(Calendar.MINUTE);
        return w;
    }
    /**
     * 获取当前秒
     * */
    public static int getCurrentSeconds(){
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        int w = cal.get(Calendar.SECOND);
        return w;
    }





}
